package cn.wolfcode.luowowo.website.web.advice;

import cn.wolfcode.luowowo.common.exception.LogicException;
import cn.wolfcode.luowowo.common.util.AjaxResult;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

@ControllerAdvice
public class CommonExceptionHandler {
    @ExceptionHandler(LogicException.class)
    @ResponseBody
    public Object logicExceptionHandle(Exception e){
        e.printStackTrace();
        return new AjaxResult(false,e.getMessage());
    }

    @ExceptionHandler(RuntimeException.class)
    @ResponseBody
    public Object runtimeExceptionHandle(Exception e){
        e.printStackTrace();
        return new AjaxResult(false,"系统异常，请通知管理员");
    }
}
